package com.zhang.mapper;

import com.zhang.entity.DeviceInfo;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * User: 张
 * Date: 2024-11-14
 * Time: 9:07
 * Description:
 */
@Mapper
public interface DeviceInfoMapper {
    @Select("select * from visions_sort.device_info;")
    public List<DeviceInfo> getAllDevice();

    @Select("select * from visions_sort.device_info where server_ip = #{serverIp};")
    public DeviceInfo getDeviceInfoByIp(String serverIp);

    @Select("select * from visions_sort.device_info where id = #{serverId}")
    public DeviceInfo getDeviceInfoById(Integer serverId);

    public List<DeviceInfo> getDeviceInfo(DeviceInfo deviceInfo);

    @Insert("insert into visions_sort.device_info (device_name, server_name, server_ip, group_id, message) " +
            "VALUE (#{deviceName}, #{serverName}, #{serverIp}, #{groupId}, #{message})")
    public int addDeviceInfo(DeviceInfo deviceInfo);

    public int updateDeviceInfo(DeviceInfo deviceInfo);
    @Update("update visions_sort.device_info set state = #{state} where id=#{id}")
    public int updateDeviceState(@Param("id") Integer id,@Param("state")Integer state);
}
